package com.exm.collectcodenew.juc.blockingqueque;

import java.util.concurrent.PriorityBlockingQueue;

public class PriorityTest {
    public static void main(String[] args)
    {

        // define capacity of PriorityBlockingQueue
        int capacityOfQueue = 2;

        // create object of PriorityBlockingQueue
        PriorityBlockingQueue<Integer> PrioQueue
                = new PriorityBlockingQueue<Integer>(capacityOfQueue);

        // Add numbers to PriorityBlockingQueue using offer()
        PrioQueue.offer(2);
        PrioQueue.offer(4);
        PrioQueue.offer(6);
        PrioQueue.offer(1);

        // print elements of PriorityBlockingQueue
        System.out.println("Queue Contains:");
        System.out.println(PrioQueue.toString());

        System.out.println("Removing item From head: "
                + PrioQueue.poll());

        System.out.println(PrioQueue.toString());
    }
}
